import React, { useEffect, useState } from 'react';
import { Button, Form, Input, Message } from 'antd';
import Upload from '@/pages/component/UpLoad.tsx';
import { history } from 'umi';
type SizeType = Parameters<typeof Form>[0]['size'];
import request from '@/utils/request';
const View: React.FC = (props: object) => {
  console.log(props, 'edit');
  const [form] = Form.useForm();
  useEffect(() => {
    console.log(props.location.query, '@@');

    form.setFieldsValue(props.location.query);
  }, []);

  const onFinish = (values: any) => {
    console.log(values, 'values');
    // request({ url: '/carouselpublish', data: values, method: 'post' }).then(
    //   (res) => {
    //     if (res.code == 0) {
    //       Message.success('提交成功', 2);
    //       form.resetFields();
    //     }
    //   },
    // );
  };

  return (
    <div style={{ paddingTop: '50px' }}>
      <Form
        form={form}
        labelCol={{ span: 8 }}
        wrapperCol={{ span: 24 }}
        layout="horizontal"
        onFinish={onFinish}
        size="large"
        style={{ maxWidth: 600 }}
      >
        <Form.Item label="活动名称" name="name">
          <Input />
        </Form.Item>
        <Form.Item label="活动链接" name="imgurl">
          <Input />
        </Form.Item>
        <Form.Item label="封面图片" name="photo">
          {<Upload></Upload>}
        </Form.Item>

        <Form.Item wrapperCol={{ offset: 13 }}>
          <Button type="primary" htmlType="submit">
            确定修改
          </Button>
          <Button
            onClick={() => {
              history.push('/carousel/list');
            }}
            type="primary"
            htmlType="reset"
            style={{ marginLeft: '20px' }}
          >
            返回
          </Button>
        </Form.Item>
      </Form>
    </div>
  );
};

export default View;
